home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / clib / printf.c < prev    next >
C/C++ Source or Header  |  1996-10-24  |  953b  |  56 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: printf.c,v 1.2 1996/10/24 15:50:20 aros Exp $
  4.  
  5.     Desc: Implementation of printf()
  6.     Lang: english
  7. */
  8.  
  9. #include <exec/execbase.h>
  10. #include <dos/dosextens.h>
  11. #include <aros/asmcall.h>
  12. #include <clib/exec_protos.h>
  13. #include <clib/dos_protos.h>
  14.  
  15. #include <stdio.h>
  16.  
  17. /* All I need is a global variable SysBase */
  18. extern struct ExecBase *SysBase;
  19.  
  20. struct Data
  21. {
  22.     int count;
  23.     BPTR file;
  24. };
  25.  
  26. AROS_UFH2(static void, _putc,
  27.     AROS_UFHA(UBYTE,         chr, D0),
  28.     AROS_UFHA(struct Data *, hd,  A3)
  29. )
  30. {
  31.     AROS_LIBFUNC_INIT
  32.  
  33.     if (hd->count >= 0)
  34.     {
  35.     if (FPutC (hd->file, chr) == EOF)
  36.         hd->count = EOF;
  37.     else
  38.         hd->count ++;
  39.     }
  40.     AROS_LIBFUNC_EXIT
  41. }
  42.  
  43. int printf(const char * format, ...)
  44. {
  45.     struct Data hd;
  46.  
  47.     hd.count = 0;
  48.     hd.file=((struct Process *)FindTask(NULL))->pr_COS;
  49.  
  50.     RawDoFmt((char *)format,&format+1,(VOID_FUNC)_putc,&hd);
  51.  
  52.     return hd.count;
  53. }
  54.  
  55.  
  56.